package cn.wolfcode.wolf2w.common.core.query;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.Getter;
import lombok.Setter;

import java.io.Serializable;

@Data
@ApiModel(value = "分页父亲", description = "分页查询对象的父亲")
public class QueryObject implements Serializable {
    @ApiModelProperty(value = "当前页", name = "currentPage", dataType = "int", example = "1")
    private int currentPage = -1;
    @ApiModelProperty(value = "当前页", name = "pageNum", dataType = "int", example = "1")
    private int pageNum = -1;
    @ApiModelProperty(value = "每页条数", name = "pageSize", dataType = "int", example = "10")
    private int pageSize = 10;
    @ApiModelProperty(value = "关键字", name = "keyword", dataType = "String", example = "广州")
    private String keyword;

    public int getCurrentPage() {
        if (currentPage != -1) {
            return this.currentPage;
        }
        if (currentPage == -1 && pageNum != -1) {
            return pageNum;
        }
        return 1;
    }

    public int getPageNum() {
        if (pageNum != -1) {
            return this.pageNum;
        }
        if (pageNum == -1 && currentPage != -1) {
            return currentPage;
        }
        return 1;
    }
}
